#include <iostream>
#include <algorithm>
#include "Student.h"
#include "SortTestHelper.h"
using namespace std;

template <typename T>
void selectionSort(T arr[],int n){
    for(int i = 0;i < n;i++){
        //寻找[i,n)区间里的最小值
        int minIndex = i;
        for(int j = i+1;j < n;j++)
            if(arr[j] < arr[minIndex])
                minIndex = j;
        swap(arr[i],arr[minIndex]);
    }
}

int main() {
    /*
    float b[4] = {4.4,3.3,2.2,1.1};
    selectionSort(b,4);
    for(int i = 0;i < 4;i++)
        cout<<b[i]<<" ";
    cout<<endl;


    string c[4] = {"D","C","B","A"};
    selectionSort(c,4);
    for(int i = 0;i < 4;i++)
        cout<<c[i]<<" ";
    cout<<endl;

    Student d[4] = {{"D",100},{"C",95},{"B",95},{"A",90}};
    selectionSort(d,4);
    for(int i = 0;i < 4;i++)
        cout<<d[i];
    cout<<endl;
     */

    int n = 100000;
    int *arr = SortTestHelper::generateRandomArray(n,0,n);
    selectionSort(arr,n);
    SortTestHelper::testSort("SelectionSort",selectionSort,arr,n);
//    SortTestHelper::printArray(arr,n);
    delete[] arr;

    return 0;
}
